package com.his.invdrug.service.Imp;

import com.his.invdrug.dao.DictInvpropOrgidMapper;
import com.his.invdrug.entity.DictInvpropOrgid;
import com.his.invdrug.service.DictInvpropOrgidService;
import com.his.invdrug.vo.DictInvpropOrgidVo;
import com.his.login.entity.DictEmployee;
import com.xiao.common.util.BeanUtil;
import com.xiao.common.util.WorkIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictInvpropOrgidServiceImpl implements DictInvpropOrgidService {

    @Autowired
    private DictInvpropOrgidMapper dictInvpropOrgidMapper;

    @Override
    public List<DictInvpropOrgid> queryByInvporpID(DictEmployee dictEmployee, String invporpID) {
        DictInvpropOrgid dictInvpropOrgid=new DictInvpropOrgid();
        dictInvpropOrgid.setInvporpid(invporpID);
        dictInvpropOrgid.setHospid(dictEmployee.getHOSPID());
        return dictInvpropOrgidMapper.selectByInvporpID(dictInvpropOrgid);
    }

    @Override
    public void insert(DictEmployee dictEmployee, DictInvpropOrgidVo dictInvpropOrgidVo) {
        DictInvpropOrgid dictInvpropOrgid=BeanUtil.copyBean(dictInvpropOrgidVo,DictInvpropOrgid.class);
        dictInvpropOrgid.setId(WorkIdUtil.nextId());
        dictInvpropOrgid.setHospid(dictEmployee.getHOSPID());
        dictInvpropOrgidMapper.insert(dictInvpropOrgid);
    }

    @Override
    public void updateBySelective(DictInvpropOrgidVo dictInvpropOrgidVo) {
        DictInvpropOrgid dictInvpropOrgid=BeanUtil.copyBean(dictInvpropOrgidVo,DictInvpropOrgid.class);
        dictInvpropOrgidMapper.updateByPrimaryKeySelective(dictInvpropOrgid);
    }

    @Override
    public void deleteByKey(String id) {
        dictInvpropOrgidMapper.deleteByPrimaryKey(id);
    }
}
